package com.exam.service.base;

import java.util.LinkedHashMap;

import com.exam.bean.QueryResult;

public interface DAO {
	
	/**
	 * 获取记录总数
	 * @param entityClass 实体类
	 * @return
	 */
	public <T> long getCount(Class<T> entityClass);
	
	
	/**
	 * save the object of entity
	 * @param entity 'the object of entity'
	 */
	public void save(Object entity);
	
	
	/**
	 * update the object of entity
	 * @param entity 'the object of entity'
	 */
	public void update(Object entity);
	
	
	/**
	 * delete the object of entity by id
	 * @param <T>
	 * @param entityClass 
	 * @param entityId 'the id of entity'
	 */
	public <T> void delete(Class<T> entityClass,Object entityId);
	
	
	/**
	 * delete the object of entity by ids
	 * @param <T>
	 * @param entityClass 
	 * @param entityIds 'the ids of entity'
	 */
	public <T> void delete(Class<T> entityClass,Object[] entityIds);
	
	
	/**
	 * get the object of entity by id
	 * @param <T>
	 * @param entityClass 
	 * @param entiyId 'the id of entity'
	 * @return
	 */
	public <T> T find(Class<T> entityClass,Object entiyId);
	
	
	/**
	 * get all the entities
	 * @param <T>
	 * @param entityClass 
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass);
	
	
	/**
	 * get the entities after the page
	 * @param <T>
	 * @param entityClass 
	 * @param firstIndex 'the start index of result'
	 * @param maxResult 'the max result'
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass,int firstIndex
			,int maxResult);
	
	
	/**
	 * 
	 * @param <T>
	 * @param entityClass 
	 * @param firstIndex
	 * @param maxResult
	 * @param orderby
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass,int firstIndex
			,int maxResult,LinkedHashMap<String,String> orderby);
	
	
	/**
	 * 
	 * @param <T>
	 * @param entityClass
	 * @param orderby 
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass
			,LinkedHashMap<String,String> orderby);
	
	
	/**
	 * 
	 * @param <T>
	 * @param entityClass 
	 * @param wherejpql 
	 * @param queryParams 
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass,String wherejpql
			,Object[] queryParams);
	
	
	/**
	 * 
	 * @param <T>
	 * @param entityClass 
	 * @param firstIndex 
	 * @param maxResult 
	 * @param wherejpql
	 * @param queryParams
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass,int firstIndex
			,int maxResult,String wherejpql,Object[] queryParams);
	
	
	/**
	 * 
	 * @param <T>
	 * @param entityClass
	 * @param firstIndex
	 * @param maxResult
	 * @param wherejpql
	 * @param queryParams
	 * @param orderby
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass,String wherejpql
			,Object[] queryParams, LinkedHashMap<String,String> orderby);
	
	
	/**
	 * 
	 * @param <T>
	 * @param entityClass
	 * @param firstIndex
	 * @param maxResult
	 * @param wherejpql
	 * @param queryParams
	 * @param orderby
	 * @return
	 */
	public <T> QueryResult<T> getScrollData(Class<T> entityClass,int firstIndex
			,int maxResult,String wherejpql,Object[] queryParams
			, LinkedHashMap<String,String> orderby);
}
